package com.example.qinghe.service.businesstrip;

import com.example.qinghe.dao.businesstrip.ReimburseMapper;
import com.example.qinghe.entity.Common;
import com.example.qinghe.entity.businesstrip.Reimburse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReimburseService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private ReimburseMapper dao;
    @Autowired
    private JourneyService journeyService;

    //添加报销申请
    public Long add(Reimburse reimburse) {
        return dao.add(reimburse);
    }

    //  //根据id:客户id eid:部门id,sid:员工id,cid:公司id name:客户名 start:查询起点，limit几条数据
    //    //返回客户的list集合
    public List<Common> sel(Common common) {
        return dao.sel(common);
    }

    //修改
    public int edit(Common common) {
        return dao.edit(common);
    }


    public int checkJourney(Long id, Long jid) {
        Common common = new Common();
        common.put("id", jid);
        common.put("start", 0);
        common.put("limit", 2);
        Common sel = journeyService.selById(common);
        if(sel==null)
            return 0;
        Long sid = (Long)sel.get("sid");
        if(sid!=id)
            return 0;
        return 1;
    }
//nnnc
    public Common selByid(Long id) {
        Common common = new Common();
        common.put("id", id);
        common.put("start", 0);
        common.put("limit", 2);
        List<Common> sel = dao.sel(common);
        if(sel.size()<1)
            return null;
        return sel.get(0);
    }

    public int del(Long id) {
        Common common = new Common();
        common.put("id", id);
        int del = dao.del(common);
        return del;

    }
    public  Common selByID(Common common)
    {
        return dao.selByID(common);
    }
}
